#! /bin/sh
#### Run GBmod with CWP PostScript Graphics
#### Create Figure 8 in the GBmod paper

if test "$PSPREVIEWER" = ""
then
echo "Environment variable PSPREVIEWER not set" ; exit 1
fi

# model
model=3

####  find the right directory
datadir=../datadir/

####  aux files
modelfile=${datadir}model${model}.data
modelpsfile=${datadir}model${model}.eps
rayendsfile=${datadir}rayend${raydemo}.data
rayfile=${datadir}ray${raydemo}.data
raypsfile1=${datadir}ray1${raydemo}.eps
raypsfile2=${datadir}ray2${raydemo}.eps

nangle=20 nxz=201 nt=20 fangle=-17 langle=-8

####   generate modelfile and modelpsfile
#../Models/PSmodel${model}

####   shoot the rays 
triray <$modelfile >$rayendsfile \
        rayfile=$rayfile nangle=$nangle \
        nxz=$nxz  xs=1 zs=0.1  krecord=1 \
        fangle=$fangle langle=$langle \
        refseq=1,-1  \
	refseq=3,0,1,0 \
	refseq=4,1,1 

####   plot the rays 
psgraph <$rayfile >$raypsfile1 \
        nplot=`cat outpar` n=$nxz \
        hbox=3.0 wbox=6.0  \
        x1beg=0 x1end=1 x2beg=0 x2end=2 \
        style=seismic linegray=1

####   shoot the rays 
triray <$modelfile >$rayendsfile \
        rayfile=$rayfile nangle=$nangle \
        nxz=$nxz  xs=1 zs=0.1 krecord=1 \
        fangle=7 langle=15 \
        refseq=1,-1 \
	refseq=2,0,1,0 \
	refseq=3,1,0,0 \
        refseq=4,1 

####   plot the rays 
psgraph <$rayfile >$raypsfile2 \
        nplot=`cat outpar` n=$nxz \
        hbox=3.0 wbox=6.0  \
        x1beg=0 x1end=1 x2beg=0 x2end=2 \
        style=seismic linegray=1

####    display rays and model
$CWPROOT/bin/psmerge in=$modelpsfile in=$raypsfile1 in=$raypsfile2 |
        $PSPREVIEWER 

exit 0

